<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>运费计算器</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/api.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/tt.css" />

    <style>
        html {
            background: rgba(243, 245, 246, 1);
        }

        body {
            width: 100%;
            height: 100%;
            background: rgba(243, 245, 246, 1);
            margin: 0;
            padding: 0;
        }

        .top {
            width: 100%;
            height: 80px;
            background: rgba(255, 255, 255, 1);
        }

        .top_box {
            width: 1180px;
            height: 100%;
            margin: 0 auto;
            align-items: center;
        }

        .top_logo {
            width: 122px;
            height: 32px;
            margin-right: 78px;
        }

        .top_label {
            position: relative;
            height: 80px;
            line-height: 80px;
            font-size: 16px;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            margin-right: 48px;
        }

        .top_label_active::after {
            position: absolute;
            content: '';
            display: block;
            height: 4px;
            width: 32px;
            left: 0;
            right: 0;
            margin: auto;
            background-color: #FC2B40;
            bottom: 17px;
        }

        .top_down {
            display: inline-block;
            width: 8px;
            height: 8px;
            min-height: 8px;
            width: 8px;
            background: url(__IMG__/down.png) no-repeat center center;
            background-size: 8px 8px;
            margin-left: 4px;
        }

        .top_avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            margin-right: 8px;
        }

        .top_name {
            font-size: 16px;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
        }

        .top_notice {
            width: 24px;
            height: 24px;
            margin-left: 58px;
        }

        .yf_money {
            width: 1180px;
            height: 120px;
            background: #fff;
            margin: 40px auto 20px;
        }

        .yf_l {
            font-size: 16px;
            color: rgba(51, 51, 51, 1);
            line-height: 120px;
            float: left;
            padding-left: 100px;
        }

        .yf_r {
            /*float: right;
            padding: 44px 100px 0 0;*/
            text-align: right;
            line-height: 83px;
            padding-right: 100px;
        }

        #y_money {
            color: #333;
            font-size: 30px;
            /*line-height: 30px;*/
            font-weight: bold;
            text-align: right;
            /*width:16px;*/
            color: #333;
            font-size: 30px;
            font-weight: bold;
        }

        .money2 {
            color: #999999;
            font-size: 20px;
            line-height: 30px;
        }

        .money2 span {
            color: #999999;
            font-size: 30px;
            font-weight: bold;
        }

        .b_out {
            background-color: #fff;
            padding: 32px 84px 32px 100px;
            margin: auto;
            width: 1180px;
            box-sizing: border-box;
        }

        .left {
            width: 150px;
            font-size: 14px;
            font-weight: 400;
            color: #666666;
        }

        .kuang {
            width: 572px;
            height: 32px;
            border-radius: 4px;
            border: 1px solid rgba(221, 221, 221, 1);
            align-items: center;
            padding-right: 12px;
            font-size: 12px;
            font-weight: 400;
            color: rgba(204, 204, 204, 1);
        }

        .kuang1 {
            width: 224px;
            height: 32px;
            border-radius: 4px;
            border: 1px solid rgba(221, 221, 221, 1);
            align-items: center;
            font-size: 12px;
            font-weight: 400;
            color: rgba(204, 204, 204, 1);
        }

        .after:after {
            display: block;
            content: '';
            clear: both;
        }

        .red {
            color: #FF3B30;
        }

        .one {
            align-items: center;
            margin-bottom: 24px;
        }

        .one1 {
            /*align-items: center;*/
            margin-bottom: 16px;
            line-height: 32px;
        }

        input[type="text"] {
            height: 32px;
            margin: 0;
            padding: 0 12px;
            font-size: 14px;
            color: #666666;
            background: transparent;
            outline: none;
        }

        input::-webkit-input-placeholder {
            color: #CCCCCC;
        }

        #y_money::-webkit-input-placeholder {
            color: #CCCCCC;
            /*font-weight: 600;*/
        }
        .down {
            width: 12px;
            height: 8px;
        }

        .car_type span {
            font-size: 14px;
            color: #666666;
            line-height: 30px;
            min-width: 104px;
            height: 32px;
            border-radius: 4px;
            border: 1px solid rgba(221, 221, 221, 1);
            text-align: center;
            display: inline-block;
            margin-right: 16px;
            box-sizing: border-box;
            margin-bottom: 8px;
            float: left;
        }

        .car_type span.active {
            color: #FC2B40;
            line-height: 32px;
            background: rgba(252, 43, 64, 0.1);
            border: none;
        }

        .btn {
            width: 88px;
            height: 32px;
            background: rgba(252, 43, 64, 1);
            border-radius: 4px;
            font-size: 14px;
            color: rgba(255, 255, 255, 1);
            line-height: 32px;
            margin: 54px auto 0;
            text-align: center;
        }
        #my-span {
            visibility: hidden;
            /*display: none;*/
        }
        .top_card1{
            position: absolute;
            top:75px;
            left:0;
            width:170px;
            background:#fff;
            border-radius:4px;
            z-index:99;
            font-size:16px;
            font-weight:400;
            overflow: hidden;
            -webkit-box-shadow:0px 0px 10px rgba(0,0,0,0.2);
        }
        .top_card2{
            height:40px;
            line-height:40px;
            background:rgba(255,255,255,1);;
            color:rgba(102,102,102,1);
            padding-left:24px;
        }
        .top_card_active{
            height:40px;
            line-height:40px;
            background:rgba(252,43,64,0.1);
            color:rgba(252,43,64,1);
            padding-left:24px;
        }
        #order,
        #about,
        #user {
            display: none;
        }
        .top_card{
            position: relative;
        }
    </style>
</head>

<body>
{include file="public/header"}

<div class="yf_money">
    <span id="my-span"></span>
    <div class="yf_l">预计运费金额</div>
    <div class="yf_r">
        <span id="fuhao">¥</span>
        <span class="money1" id="y_money"></span>
        <!--<input type="text" value="" >-->
    </div>
</div>
<div class="b_out">
    <div class="one flex-wrap">
        <div class="left">选择出发地</div>
        <div class="kuang flex-wrap">
            <input type="text" placeholder="请选择"  class="flex-con go_address">
            <img src="__IMG__/down1.png" class="down">
        </div>
    </div>
    <div class="one flex-wrap">
        <div class="left">选择目的地</div>
        <div class="kuang flex-wrap">
            <input type="text" placeholder="请选择"  class="flex-con to_address">
            <img src="__IMG__/down1.png" class="down">
        </div>
    </div>
    <div class="one flex-wrap">
        <div class="left">重量</div>
        <div class="kuang flex-wrap">
            <input type="text" placeholder="请输入货物重量"  class="flex-con">
            <!-- <img src="__IMG__/down1.png" class="down"> -->
        </div>
    </div>
    <div class="one1 flex-wrap">
        <div class="left">车型</div>
        <div class="flex-con car_type" id="box1">
            {volist name="list1" id="vv"}
            <span class="label" onclick="choose1(this)" name="{$vv['cx_name']}" >{$vv['cx_name']}</span>
            {/volist}
        </div>
    </div>
    <div class="one1 flex-wrap">
        <div class="left">车长</div>
        <div class="flex-con car_type"  id="box2">
            <div class="after">
                {volist name="list" id="vo"}
                <span class="label" onclick="choose2(this)" name="{$vo['cclb_name']}" >{$vo['cclb_name']}</span>
                {/volist}
            </div>
        </div>

    </div>
    <div class="btn" onclick="submit()">计算</div>
</div>
</body>
<script src="__SCRIPT__/api.js" charset="utf-8"></script>
<script type="text/javascript" src="__SCRIPT__/xydd.js"></script>
<script src="/static/admin/js/jquery.min.js"></script>
<!--<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=1e0d12c4fc7710d9c326e672ac6f26c2&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocode"></script>-->

<script type="text/javascript">
    var cc='';//车长
    var cx='';//车型
    function choose1(el){
        // var type=$api.attr(el,'type');
        var itemAll=$api.domAll($api.byId('box1'),'.label');
        for(var i=0;i<itemAll.length;i++){
            $api.removeCls(itemAll[i], 'active');
        }
        $api.addCls(el,'active');
        cx=$api.attr(el,'name');

    }
    function choose2(el){
        var itemAll=$api.domAll($api.byId('box2'),'.label');
        for(var i=0;i<itemAll.length;i++){
            $api.removeCls(itemAll[i], 'active');
        }
        $api.addCls(el,'active');
        cc=$api.attr(el,'name');
    }
    function submit(){
        var go_address = $(".go_address").val();
        var to_address = $(".to_address").val();
        if(go_address==''){
            alert("出发地不能为空");
        }
        if(to_address==''){
            alert("目的地地不能为空");
        }
        if(cc==''){
            alert("车长不能为空");
        }
        $.ajax({
            url:"{:url('shop/freight/index')}",
            type:'post',
            data:{cc:cc,cx:cx,go_address:go_address,to_address:to_address},
            dataType:'json',
            success:function(res){
                if(res.status != 200){
                    alert(res.msg);
                    location.reload() ;
                    return false;
                }else{
                    $(".money1").html(res.msg);
//                    window.location.href='/shop/first/index';
                }
            }
        })
    }
    //基本地图加载
    var map = new AMap.Map("container", {
        resizeEnable: true,
        center: [116.397428, 39.90923],//地图中心点
        zoom: 13 //地图显示的缩放级别
    });

    var driving = new AMap.Driving({
        map: map,
        panel: "panel"
    });
    // 根据起终点经纬度规划驾车导航路线
    driving.search(new AMap.LngLat(116.379028, 39.865042), new AMap.LngLat(116.427281, 39.903719), function(status, result) {
        // result 即是对应的驾车导航信息，相关数据结构文档请参考  https://lbs.amap.com/api/javascript-api/reference/route-search#m_DrivingResult
        if (status === 'complete') {
            console.log(result);
            log.success('绘制驾车路线完成')
        } else {
            log.error('获取驾车数据失败：' + result)
        }
    });
    //    function changeWidth() {
//        var mySpan = $api.byId("my-span");
//        var myInput = $api.byId("y_money");
//        mySpan.innerHTML=myInput.value;
//        if (parseInt($api.cssVal(mySpan,'width')) > 0) {
//            var aaa=parseInt($api.cssVal(mySpan,'width'));
//            $api.css(myInput,'width:'+aaa*1.8+'px');
//            $api.css($api.byId('fuhao'), 'color:#333');
//
//        }else{
//            $api.css(myInput,'width:16px');
//            $api.css($api.byId('fuhao'), 'color:#999');
//        }
//    }
</script>

</html>
